test(examples): retry background sidecar on transient port-bind flake#1101
Merged
acroca merged 2 commits intoJun 30, 2026
Merged
Conversation
`test_demo_actor` flakes when the demo-actor sidecar, started via `DaprRunner.start()`, loses a random-port race at boot: daprd assigns the same port to its API and internal gRPC servers, the internal listener fails with "bind: address already in use", and the runtime exits with "could not listen on any endpoint". The actor host is then dead, so the client's `invoke_method` fails with "did not find address for actor" and the expected output never appears. PR dapr#1030 already added this retry to the foreground `run()` path, but the background `start()` path was left uncovered. Apply the same exponential backoff retry there, reusing the existing failure markers. The captured log is only read once the process has exited (`poll()` is not None), so a healthy long-lived sidecar is never inspected and its append offset is left untouched. Adds unit tests mirroring the existing `run()` coverage. Fixes dapr#1061 Signed-off-by: Kshitiz Jain <kshitizj@gmail.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1101 +/- ##
==========================================
- Coverage 86.63% 82.15% -4.48%
==========================================
Files 84 116 +32
Lines 4473 9578 +5105
==========================================
+ Hits 3875 7869 +3994
- Misses 598 1709 +1111 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR reduces flakes in the examples test suite by making DaprRunner.start() resilient to a known transient Dapr sidecar startup failure (random-port bind collision), mirroring the retry behavior already implemented for DaprRunner.run().
Changes:
- Add exponential-backoff retry logic to
DaprRunner.start()when startup output matches the existing port-bind failure markers. - Add unit tests covering the retry and non-retry paths for
start()using a background-process stand-in.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
tests/examples/conftest.py |
Adds port-bind collision retry logic to DaprRunner.start() and introduces a helper to detect the failure safely for background sidecars. |
tests/examples/test_dapr_runner.py |
Adds unit tests for start() retry behavior and introduces a fake background process for deterministic output simulation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
acroca
approved these changes
Jun 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
test_demo_actorflakes when the demo-actor sidecar, started viaDaprRunner.start(), loses a random-port race at boot: daprd assigns the same port to its API and internal gRPC servers, the internal listener fails with "bind: address already in use", and the runtime exits with "could not listen on any endpoint". The actor host is then dead, so the client'sinvoke_methodfails with "did not find address for actor" and the expected output never appears.PR #1030 already added this retry to the foreground
run()path, but the backgroundstart()path was left uncovered. This applies the same exponential backoff retry there, reusing the existing failure markers. The captured log is only read once the process has exited (poll()is not None), so a healthy long-lived sidecar is never inspected and its append offset is left untouched.Adds unit tests mirroring the existing
run()coverage.Fixes #1061
Checklist
Please make sure you've completed the relevant tasks for this PR, out of the following list: